package io.renren.modules.backstage.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.backstage.entity.IntegralEntity;
import io.renren.modules.backstage.service.IntegralService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 信用积分额度表
 *
 * @author syh
 * @email sunlightcs@gmail.com
 * @date 2022-05-20 17:14:54
 */
@RestController
@RequestMapping("backstage/integral")
public class IntegralController {
    @Autowired
    private IntegralService integralService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("crud:integral:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = integralService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{inteId}")
    @RequiresPermissions("crud:integral:info")
    public R info(@PathVariable("inteId") Integer inteId){
		IntegralEntity integral = integralService.getById(inteId);

        return R.ok().put("integral", integral);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("crud:integral:save")
    public R save(@RequestBody IntegralEntity integral){
		integralService.save(integral);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("crud:integral:update")
    public R update(@RequestBody IntegralEntity integral){
		integralService.updateById(integral);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("crud:integral:delete")
    public R delete(@RequestBody Integer[] inteIds){
		integralService.removeByIds(Arrays.asList(inteIds));

        return R.ok();
    }

}
